<extend name="desktop_default/template/user/base_user" />
<block name="area_header">
    <link rel="stylesheet" href="__CSS__/user/sethead/style.css">
    <script src="http://open.web.meitu.com/sources/xiuxiu.js" type="text/javascript"></script>
</block>

<block name="area_top">

</block>
<block name="user_top">

</block>
<block name="main_content">
    <div class="sethead">
        <div class="user-tab">
            <a href="{:U('mengwu/user/info')}">基本信息</a>
            <a class="selected" href="javascript:void(0);">头像上传</a>
        </div>
        <div id="altContent">
            <h1>头像上传</h1>
        </div>
        <div class="tip">
            仅支持jpg、png图片文件，且文件小于500kb
        </div>
    </div>

</block>
<block name="area_footer">
    <script type="text/javascript">
        window.onload=function(){

            xiuxiu.setLaunchVars("uploadBtnLabel", '确认上传');//确定按钮的文字
            //xiuxiu.setLaunchVars("cameraEnabled", 0);  //去掉摄像头功能用这句
            /*第1个参数是加载编辑器div容器，第2个参数是编辑器类型，第3个参数是div容器宽，第4个参数是div容器高*/
            xiuxiu.embedSWF("altContent",5,"600px","400px");
            //修改为您自己的图片上传接口
            xiuxiu.setUploadURL("http://www.moodwo.com/index.php/mengwu/Fileupload/index/type/avatar");//后台处理地址，本地用
            xiuxiu.setUploadType(2);
            xiuxiu.setUploadDataFieldName("image");
            xiuxiu.onInit = function ()
            {
                xiuxiu.loadPhoto("{$head}");//这是默认载入图片
            }
            //下面部分控制文件大小
            xiuxiu.onBeforeUpload = function (data, id)
            {
                var size = data.size;
                if(size > 500* 1024)
                {
                    alert("图片不能超过500kb");
                    return false;
                }
                return true;
            }
            //上传之后的操作，需要后台配合
            xiuxiu.onUploadResponse = function (data)
            {
                data = JSON.parse(data);
                if(data.status){
                    antd.message.success('上传成功');
                    setTimeout(function(){
                        window.location.reload();
                    },500);
                }else{
                    antd.message.error('上传失败');
                }
            }
            //xiuxiu.onClose = function(id) {} 关闭界面
        }
    </script>
</block>
